package com.retail.booking.controller;

import com.retail.booking.entity.request.BookingXiaohesuanRequest;
import com.retail.booking.entity.vo.BookingXiaohesuanVo;
import com.retail.booking.service.BookingXiaohesuanService;
import com.retail.core.common.AbstractCommonController;
import com.retail.core.entity.ParamReq;
import com.retail.core.entity.result.PageResult;
import com.retail.core.entity.result.Result;
import com.retail.global.annon.TraceLog;
import com.retail.global.security.LoginUserUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 小核酸预约 API
 *
 * @author Administrator
 */
@Api(tags = "小核酸预约 API")
@RestController
@RequestMapping("/bookingXiaohesuan")
public class BookingXiaohesuanController extends AbstractCommonController<BookingXiaohesuanService, BookingXiaohesuanRequest, BookingXiaohesuanVo> {

    private final BookingXiaohesuanService bookingXiaohesuanService;

    public BookingXiaohesuanController(BookingXiaohesuanService bookingXiaohesuanService) {
        this.bookingXiaohesuanService = bookingXiaohesuanService;
    }

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(bookingXiaohesuanService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存小核酸预约")
    public Result<Integer> save(@RequestBody BookingXiaohesuanRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(bookingXiaohesuanService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新小核酸预约")
    public Result<Integer> update(@RequestBody BookingXiaohesuanRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(bookingXiaohesuanService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("小核酸预约-查询")
    public Result<List<BookingXiaohesuanVo>> listPage(@RequestBody ParamReq req) {
        req.setManagerDept(LoginUserUtil.getPrincipal().getManagerDept());
        return super.listPage(bookingXiaohesuanService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("小核酸预约-统计")
    public Result<Integer> countPage(@RequestBody ParamReq req) {
        req.setManagerDept(LoginUserUtil.getPrincipal().getManagerDept());
        return super.countPage(bookingXiaohesuanService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("小核酸预约-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<BookingXiaohesuanRequest> req) {
        req.setManagerDept(LoginUserUtil.getPrincipal().getManagerDept());
        return super.page(bookingXiaohesuanService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除小核酸预约")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(bookingXiaohesuanService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除小核酸预约")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(List<Long> ids) {
        return super.batchDelete(bookingXiaohesuanService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
